// pages/news/information/information.js
const app = getApp()
var CONFIG = require("../../../config/config.js");
Page({

    /**
     * 页面的初始数据
     */
    data: {
        data:[],
        phone:'',
        page:0,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that = this;
        var phone = wx.getStorageSync('tel');
        that.setData({
            phone:phone
        })
        wx.showLoading({
            title: '加载中~',
        })
        that.auditMessage();
    },

    auditMessage(){
        var that = this;
        var phone = that.data.phone;
        var page = that.data.page;
        if(phone==''){
            var phone1 = wx.getStorageSync('tel')
        }else{
            var phone1 = phone
        }
        wx.request({
            url: CONFIG.API_HOST + 'crm/Roleauth/auditMessage',
            data: {
                phone: phone1,
                page:page
            },
            method: 'GET',
            success: function (res) {
                wx.hideLoading();
                if (res.data.status == 1001 || res.data.status == '1001') {
                    var list = res.data.data;
                    var data = that.data.data;
                    // console.log(data);
                    that.setData({
                        data:data.concat(list)
                    })
                    if (data.length == 0 || data.length == "0"){
                        that.setData({
                            msg: '暂无消息',
                        })
                    }
                } else {
                    that.setData({
                        msg: res.data.msg,
                    })
                }
            }
        })
    },

   

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
        var that = this;
        var page = that.data.page;
        page++
        that.setData({
            page:page
        })
        that.auditMessage();
    },

})